home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / cpkocx17 / briscola.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1998-07-17  |  32.7 KB  |  1,014 lines

  1. VERSION 4.00
  2. Begin VB.Form Game 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H00808000&
  5.    Caption         =   "Briscola"
  6.    ClientHeight    =   6930
  7.    ClientLeft      =   1020
  8.    ClientTop       =   1875
  9.    ClientWidth     =   7815
  10.    ClipControls    =   0   'False
  11.    FillColor       =   &H00C0C0C0&
  12.    FillStyle       =   0  'Solid
  13.    BeginProperty Font 
  14.       name            =   "MS Sans Serif"
  15.       charset         =   1
  16.       weight          =   700
  17.       size            =   8.25
  18.       underline       =   0   'False
  19.       italic          =   0   'False
  20.       strikethrough   =   0   'False
  21.    EndProperty
  22.    ForeColor       =   &H00C0C0C0&
  23.    Height          =   7620
  24.    HelpContextID   =   110
  25.    Icon            =   "BRISCOLA.frx":0000
  26.    KeyPreview      =   -1  'True
  27.    Left            =   960
  28.    LinkMode        =   1  'Source
  29.    LinkTopic       =   "game"
  30.    MaxButton       =   0   'False
  31.    ScaleHeight     =   6930
  32.    ScaleWidth      =   7815
  33.    Top             =   1245
  34.    Width           =   7935
  35.    Begin VB.PictureBox StatusLine 
  36.       Align           =   2  'Align Bottom
  37.       Height          =   450
  38.       Left            =   0
  39.       ScaleHeight     =   390
  40.       ScaleWidth      =   7755
  41.       TabIndex        =   0
  42.       Top             =   6480
  43.       Width           =   7815
  44.       Begin VB.Label Score 
  45.          Alignment       =   2  'Center
  46.          BorderStyle     =   1  'Fixed Single
  47.          Caption         =   "Score"
  48.          Height          =   285
  49.          Left            =   5640
  50.          TabIndex        =   3
  51.          Top             =   60
  52.          Width           =   2085
  53.       End
  54.       Begin VB.Label MessageView 
  55.          Alignment       =   2  'Center
  56.          BorderStyle     =   1  'Fixed Single
  57.          Caption         =   "MessageView"
  58.          Height          =   285
  59.          Left            =   1545
  60.          TabIndex        =   2
  61.          Top             =   60
  62.          Width           =   4005
  63.       End
  64.       Begin VB.Label Mode 
  65.          Alignment       =   2  'Center
  66.          BorderStyle     =   1  'Fixed Single
  67.          Caption         =   "Mode"
  68.          Height          =   285
  69.          Left            =   60
  70.          TabIndex        =   1
  71.          Top             =   60
  72.          Width           =   1455
  73.       End
  74.    End
  75.    Begin VB.PictureBox ToolBar 
  76.       Align           =   1  'Align Top
  77.       ForeColor       =   &H80000008&
  78.       Height          =   495
  79.       Left            =   0
  80.       ScaleHeight     =   435
  81.       ScaleWidth      =   7755
  82.       TabIndex        =   4
  83.       Top             =   0
  84.       Width           =   7815
  85.       Begin VB.CommandButton ToolButton 
  86.          Caption         =   "Pause"
  87.          Height          =   255
  88.          Index           =   1
  89.          Left            =   2100
  90.          TabIndex        =   22
  91.          Tag             =   "Pause Game"
  92.          Top             =   120
  93.          Width           =   915
  94.       End
  95.       Begin VB.CommandButton ToolButton 
  96.          Caption         =   "Stop"
  97.          Height          =   255
  98.          Index           =   2
  99.          Left            =   3000
  100.          TabIndex        =   11
  101.          Tag             =   "Stop game in progress"
  102.          Top             =   120
  103.          Width           =   615
  104.       End
  105.       Begin VB.CommandButton ToolButton 
  106.          Caption         =   "Hint"
  107.          Height          =   255
  108.          Index           =   5
  109.          Left            =   4020
  110.          TabIndex        =   8
  111.          Tag             =   "Suggest Card"
  112.          Top             =   120
  113.          Width           =   615
  114.       End
  115.       Begin VB.CommandButton ToolButton 
  116.          Caption         =   "Save"
  117.          Height          =   255
  118.          Index           =   4
  119.          Left            =   720
  120.          TabIndex        =   7
  121.          Tag             =   "Save this Game"
  122.          Top             =   120
  123.          Width           =   615
  124.       End
  125.       Begin VB.CommandButton ToolButton 
  126.          Caption         =   "Open"
  127.          Height          =   255
  128.          Index           =   3
  129.          Left            =   120
  130.          TabIndex        =   6
  131.          Tag             =   "Open a Saved Game"
  132.          Top             =   120
  133.          Width           =   615
  134.       End
  135.       Begin VB.CommandButton ToolButton 
  136.          Caption         =   "Start"
  137.          Height          =   255
  138.          Index           =   0
  139.          Left            =   1500
  140.          TabIndex        =   5
  141.          Tag             =   "Start a New Game"
  142.          Top             =   120
  143.          Width           =   615
  144.       End
  145.    End
  146.    Begin VB.PictureBox Table 
  147.       Appearance      =   0  'Flat
  148.       BackColor       =   &H00808000&
  149.       ForeColor       =   &H80000008&
  150.       Height          =   6015
  151.       Left            =   0
  152.       ScaleHeight     =   399
  153.       ScaleMode       =   3  'Pixel
  154.       ScaleWidth      =   519
  155.       TabIndex        =   9
  156.       Top             =   480
  157.       Width           =   7815
  158.       Begin VB.Timer GameTimer 
  159.          Enabled         =   0   'False
  160.          Interval        =   3000
  161.          Left            =   2460
  162.          Top             =   900
  163.       End
  164.       Begin Cardpk.Cardpack DragCards 
  165.          Height          =   1440
  166.          Left            =   2580
  167.          TabIndex        =   23
  168.          Top             =   1800
  169.          Visible         =   0   'False
  170.          Width           =   1065
  171.          _version        =   65536
  172.          _extentx        =   1879
  173.          _extenty        =   2540
  174.          _stockprops     =   65
  175.          cardslibrary    =   "cards.dll"
  176.          numcards        =   0
  177.          stackfacing     =   1
  178.       End
  179.       Begin MSComDlg.CommonDialog DialogObj 
  180.          Left            =   2400
  181.          Top             =   360
  182.          _version        =   65536
  183.          _extentx        =   847
  184.          _extenty        =   847
  185.          _stockprops     =   0
  186.          flags           =   20
  187.          helpcommand     =   1
  188.          helpcontext     =   500
  189.       End
  190.       Begin Cardpk.Cardpack Deck 
  191.          Height          =   1740
  192.          Left            =   5700
  193.          TabIndex        =   15
  194.          Top             =   1860
  195.          Width           =   1365
  196.          _version        =   65536
  197.          _extentx        =   2408
  198.          _extenty        =   3069
  199.          _stockprops     =   65
  200.          cardslibrary    =   "cards.dll"
  201.          autosize        =   0   'False
  202.          spreadstyle     =   1
  203.          spreaddir       =   4
  204.          drawstephoriz   =   1
  205.          drawstepvert    =   -1
  206.          drawcardevery   =   2
  207.          drawstarty      =   20
  208.       End
  209.       Begin Cardpk.Cardpack Player1 
  210.          Height          =   1440
  211.          Left            =   120
  212.          TabIndex        =   16
  213.          Top             =   4080
  214.          Width           =   2115
  215.          _version        =   65536
  216.          _extentx        =   3731
  217.          _extenty        =   2540
  218.          _stockprops     =   65
  219.          cardslibrary    =   "cards.dll"
  220.          spreadstyle     =   3
  221.          spreaddir       =   2
  222.          drawstephoriz   =   35
  223.          packonremove    =   0   'False
  224.          numcards        =   3
  225.          stackfacing     =   1
  226.       End
  227.       Begin Cardpk.Cardpack Player2 
  228.          Height          =   1440
  229.          Left            =   60
  230.          TabIndex        =   17
  231.          Top             =   180
  232.          Width           =   2115
  233.          _version        =   65536
  234.          _extentx        =   3731
  235.          _extenty        =   2540
  236.          _stockprops     =   65
  237.          cardslibrary    =   "cards.dll"
  238.          spreadstyle     =   3
  239.          spreaddir       =   2
  240.          drawstephoriz   =   35
  241.          packonremove    =   0   'False
  242.          numcards        =   3
  243.       End
  244.       Begin Cardpk.Cardpack OnTable 
  245.          Height          =   1440
  246.          Left            =   180
  247.          TabIndex        =   18
  248.          Top             =   2160
  249.          Width           =   2145
  250.          _version        =   65536
  251.          _extentx        =   3784
  252.          _extenty        =   2540
  253.          _stockprops     =   65
  254.          cardslibrary    =   "cards.dll"
  255.          spreadstyle     =   4
  256.          spreaddir       =   2
  257.          drawstephoriz   =   72
  258.          numcards        =   2
  259.          stackfacing     =   1
  260.       End
  261.       Begin Cardpk.Cardpack Briscola 
  262.          Height          =   1440
  263.          Left            =   4620
  264.          TabIndex        =   19
  265.          Top             =   2160
  266.          Width           =   1065
  267.          _version        =   65536
  268.          _extentx        =   1879
  269.          _extenty        =   2540
  270.          _stockprops     =   65
  271.          cardslibrary    =   "cards.dll"
  272.          numcards        =   0
  273.          stackfacing     =   1
  274.       End
  275.       Begin Cardpk.Cardpack Stack2 
  276.          Height          =   1440
  277.          Left            =   3780
  278.          TabIndex        =   20
  279.          Top             =   180
  280.          Width           =   1065
  281.          _version        =   65536
  282.          _extentx        =   1879
  283.          _extenty        =   2540
  284.          _stockprops     =   65
  285.          cardslibrary    =   "cards.dll"
  286.          spreadstyle     =   1
  287.          spreaddir       =   4
  288.          drawstephoriz   =   1
  289.          drawstepvert    =   -1
  290.          drawcardevery   =   2
  291.          numcards        =   0
  292.       End
  293.       Begin Cardpk.Cardpack Stack1 
  294.          Height          =   1440
  295.          Left            =   3900
  296.          TabIndex        =   21
  297.          Top             =   4080
  298.          Width           =   1065
  299.          _version        =   65536
  300.          _extentx        =   1879
  301.          _extenty        =   2540
  302.          _stockprops     =   65
  303.          cardslibrary    =   "cards.dll"
  304.          spreadstyle     =   1
  305.          spreaddir       =   4
  306.          drawstephoriz   =   1
  307.          drawstepvert    =   -1
  308.          drawcardevery   =   2
  309.          numcards        =   0
  310.       End
  311.       Begin VB.Label Player2Name 
  312.          Appearance      =   0  'Flat
  313.          BackColor       =   &H80000005&
  314.          BackStyle       =   0  'Transparent
  315.          Caption         =   "Computer"
  316.          BeginProperty Font 
  317.             name            =   "MS Sans Serif"
  318.             charset         =   1
  319.             weight          =   700
  320.             size            =   12
  321.             underline       =   0   'False
  322.             italic          =   0   'False
  323.             strikethrough   =   0   'False
  324.          EndProperty
  325.          ForeColor       =   &H80000008&
  326.          Height          =   285
  327.          Left            =   5220
  328.          TabIndex        =   10
  329.          Top             =   60
  330.          Width           =   1605
  331.       End
  332.       Begin VB.Label Score2 
  333.          Appearance      =   0  'Flat
  334.          BackColor       =   &H80000005&
  335.          BackStyle       =   0  'Transparent
  336.          Caption         =   "Score2"
  337.          BeginProperty Font 
  338.             name            =   "MS Sans Serif"
  339.             charset         =   1
  340.             weight          =   700
  341.             size            =   12
  342.             underline       =   0   'False
  343.             italic          =   0   'False
  344.             strikethrough   =   0   'False
  345.          EndProperty
  346.          ForeColor       =   &H80000008&
  347.          Height          =   285
  348.          Left            =   6900
  349.          TabIndex        =   13
  350.          Top             =   60
  351.          Width           =   795
  352.       End
  353.       Begin VB.Shape Shape1 
  354.          BackColor       =   &H00008000&
  355.          BackStyle       =   1  'Opaque
  356.          Height          =   375
  357.          Index           =   0
  358.          Left            =   5100
  359.          Top             =   60
  360.          Width           =   2655
  361.       End
  362.       Begin VB.Label Score1 
  363.          Appearance      =   0  'Flat
  364.          BackColor       =   &H80000005&
  365.          BackStyle       =   0  'Transparent
  366.          Caption         =   "Score1"
  367.          BeginProperty Font 
  368.             name            =   "MS Sans Serif"
  369.             charset         =   1
  370.             weight          =   700
  371.             size            =   12
  372.             underline       =   0   'False
  373.             italic          =   0   'False
  374.             strikethrough   =   0   'False
  375.          EndProperty
  376.          ForeColor       =   &H80000008&
  377.          Height          =   285
  378.          Left            =   6900
  379.          TabIndex        =   14
  380.          Top             =   5640
  381.          Width           =   795
  382.       End
  383.       Begin VB.Label Player1Name 
  384.          Appearance      =   0  'Flat
  385.          BackColor       =   &H80000005&
  386.          BackStyle       =   0  'Transparent
  387.          Caption         =   "Player"
  388.          BeginProperty Font 
  389.             name            =   "MS Sans Serif"
  390.             charset         =   1
  391.             weight          =   700
  392.             size            =   12
  393.             underline       =   0   'False
  394.             italic          =   0   'False
  395.             strikethrough   =   0   'False
  396.          EndProperty
  397.          ForeColor       =   &H80000008&
  398.          Height          =   285
  399.          Left            =   5220
  400.          TabIndex        =   12
  401.          Top             =   5640
  402.          Width           =   1605
  403.       End
  404.       Begin VB.Shape Shape1 
  405.          BackColor       =   &H00008000&
  406.          BackStyle       =   1  'Opaque
  407.          Height          =   375
  408.          Index           =   1
  409.          Left            =   5100
  410.          Top             =   5580
  411.          Width           =   2655
  412.       End
  413.    End
  414.    Begin VB.Menu FileMenu 
  415.       Caption         =   "&Game"
  416.       HelpContextID   =   102
  417.       Begin VB.Menu FileNew 
  418.          Caption         =   "&New Game    F2"
  419.       End
  420.       Begin VB.Menu FilePause 
  421.          Caption         =   "&Pause Game F3"
  422.       End
  423.       Begin VB.Menu FileStop 
  424.          Caption         =   "&Stop Game    F12"
  425.       End
  426.       Begin VB.Menu FileHint 
  427.          Caption         =   "Give &Hint       F11"
  428.       End
  429.       Begin VB.Menu msep4 
  430.          Caption         =   "-"
  431.       End
  432.       Begin VB.Menu FileOpen 
  433.          Caption         =   "&Open...          F4"
  434.       End
  435.       Begin VB.Menu FileSave 
  436.          Caption         =   "Sa&ve             F5"
  437.       End
  438.       Begin VB.Menu FileSaveAs 
  439.          Caption         =   "Sav&e As...     F6"
  440.       End
  441.       Begin VB.Menu FileRecent 
  442.          Caption         =   "-"
  443.          Index           =   0
  444.          Visible         =   0   'False
  445.       End
  446.       Begin VB.Menu FileRecent 
  447.          Caption         =   ""
  448.          Index           =   1
  449.          Visible         =   0   'False
  450.       End
  451.       Begin VB.Menu FileRecent 
  452.          Caption         =   ""
  453.          Index           =   2
  454.          Visible         =   0   'False
  455.       End
  456.       Begin VB.Menu FileRecent 
  457.          Caption         =   ""
  458.          Index           =   3
  459.          Visible         =   0   'False
  460.       End
  461.       Begin VB.Menu FileRecent 
  462.          Caption         =   ""
  463.          Index           =   4
  464.          Visible         =   0   'False
  465.       End
  466.       Begin VB.Menu FileRecent 
  467.          Caption         =   ""
  468.          Index           =   5
  469.          Visible         =   0   'False
  470.       End
  471.       Begin VB.Menu MenuSep2 
  472.          Caption         =   "-"
  473.       End
  474.       Begin VB.Menu FileExit 
  475.          Caption         =   "E&xit"
  476.       End
  477.    End
  478.    Begin VB.Menu MenuSettings 
  479.       Caption         =   "&Options"
  480.       Begin VB.Menu OptToolBar 
  481.          Caption         =   "Show &Tool Bar"
  482.          Checked         =   -1  'True
  483.       End
  484.       Begin VB.Menu OptStatusBar 
  485.          Caption         =   "Show &Status Bar"
  486.          Checked         =   -1  'True
  487.       End
  488.       Begin VB.Menu OptSound 
  489.          Caption         =   "Sound &Effects"
  490.       End
  491.       Begin VB.Menu OptAnimate 
  492.          Caption         =   "Card &Animations"
  493.          Visible         =   0   'False
  494.       End
  495.       Begin VB.Menu OptTrace 
  496.          Caption         =   "&Debug Window"
  497.       End
  498.       Begin VB.Menu OptPeek 
  499.          Caption         =   "&Peek Cards"
  500.       End
  501.       Begin VB.Menu mSep1 
  502.          Caption         =   "-"
  503.       End
  504.       Begin VB.Menu mGameOptions 
  505.          Caption         =   "Game Options"
  506.       End
  507.    End
  508.    Begin VB.Menu MenuHelp 
  509.       Caption         =   "&Help"
  510.       HelpContextID   =   501
  511.       Begin VB.Menu HelpContents 
  512.          Caption         =   "&Contents"
  513.       End
  514.       Begin VB.Menu HelpUsingHelp 
  515.          Caption         =   "&Using Help"
  516.       End
  517.       Begin VB.Menu MenuSep3 
  518.          Caption         =   "-"
  519.       End
  520.       Begin VB.Menu HelpAbout 
  521.          Caption         =   "&About..."
  522.       End
  523.    End
  524. Attribute VB_Name = "Game"
  525. Attribute VB_Creatable = False
  526. Attribute VB_Exposed = False
  527. ' Constants and declarations.
  528. Const BRISCOLA_HELP_TUTOR = 110
  529. ' Toolbar Buttons
  530. Const BTN_START = 0
  531. Const BTN_PAUSE = 1
  532. Const BTN_STOP = 2
  533. Const BTN_FILEOPEN = 3
  534. Const BTN_FILESAVE = 4
  535. Const BTN_HINT = 5
  536. Const BTN_HELPCONTEXT = 10
  537. Const BTN_HELPCONTENTS = 11
  538. Sub ModePause()
  539.     FileNew.Enabled = True
  540.     FileOpen.Enabled = True
  541.     FileSave.Enabled = True
  542.     FileSaveAs.Enabled = True
  543.     FilePause.Enabled = True
  544.     FilePause.Checked = True
  545.     FileStop.Enabled = True
  546.     ToolButton(BTN_START).Enabled = True
  547.     ToolButton(BTN_PAUSE).Enabled = True
  548.     ToolButton(BTN_STOP).Enabled = True
  549.     ToolButton(BTN_FILEOPEN).Enabled = True
  550.     ToolButton(BTN_FILESAVE).Enabled = True
  551.     ToolButton(BTN_HINT).Enabled = False
  552. End Sub
  553. Sub ModeRun()
  554.     FileNew.Enabled = 0
  555.     FileOpen.Enabled = 0
  556.     FileSave.Enabled = 0
  557.     FileSaveAs.Enabled = 0
  558.     FilePause.Enabled = True
  559.     FilePause.Checked = False
  560.     FileStop.Enabled = True
  561.     FileHint.Enabled = (Game_Mode <> MODE_DEMO)
  562.     ToolButton(BTN_START).Enabled = False
  563.     ToolButton(BTN_PAUSE).Enabled = True
  564.     ToolButton(BTN_STOP).Enabled = True
  565.     ToolButton(BTN_FILEOPEN).Enabled = False
  566.     ToolButton(BTN_FILESAVE).Enabled = False
  567.     ToolButton(BTN_HINT).Enabled = (Game_Mode <> MODE_DEMO)
  568.     Game.Player1Name = Player1_Name & ": "
  569.     Game.Player2Name = Player2_Name & ": "
  570. End Sub
  571. Sub ModeStop()
  572.     FileNew.Enabled = True
  573.     FileOpen.Enabled = True
  574.     FileSave.Enabled = True
  575.     FileSaveAs.Enabled = True
  576.     FilePause.Enabled = False
  577.     FilePause.Checked = False
  578.     FileStop.Enabled = False
  579.     ToolButton(BTN_START).Enabled = True
  580.     ToolButton(BTN_FILEOPEN).Enabled = True
  581.     ToolButton(BTN_FILESAVE).Enabled = True
  582.     ToolButton(BTN_PAUSE).Enabled = False
  583.     ToolButton(BTN_STOP).Enabled = False
  584.     ToolButton(BTN_HINT).Enabled = False
  585. End Sub
  586. Sub MoveCard(cFrom As Cardpack, idx%, cTo As Cardpack)
  587.     Dim steps%, i%, c%
  588.     Dim dx%, dy%
  589.     Dim tx%, ty%
  590.     Dim cx%, cy%
  591.     Const ANIM_SPEED = 10
  592.     ' In VB5 .Move does not work very well. Disable it.
  593. #If Win32 Then
  594.     cTo.TopCard = cFrom.RemoveCard(idx%)
  595.     DragCards.Visible = False
  596.     DoEvents
  597.     Sleep 0.1
  598.     Exit Sub
  599. #End If
  600.     ' calc coordinates of source and target position
  601.     cx% = cFrom.Left + cFrom.DrawStartX + idx% * cFrom.DrawStepHoriz
  602.     cy% = cFrom.Top + cFrom.DrawStartY + idx% * cFrom.DrawStepVert
  603.     tx% = cTo.Left + cTo.DrawStartX + cTo.NumCards * cTo.DrawStepHoriz
  604.     ty% = cTo.Top + cTo.DrawStartY + cTo.NumCards * cTo.DrawStepVert
  605.     ' calc # of steps as max distance \ speed
  606.     dx% = Abs(tx% - cx%)
  607.     dy% = Abs(ty% - cy%)
  608.     If dx% > dy% Then steps% = dx% Else steps% = dy%
  609.     steps% = steps% \ ANIM_SPEED
  610.     ' pick card and move it to the "dragging" control
  611.     DragCards.NumCards = 0
  612.     DragCards.TopCard = cFrom.Card(idx%)
  613.     DragCards.ZOrder     ' in VB4/16 once ain't enough the 1st time
  614.     DragCards.ZOrder
  615.     DragCards.StackFacing = cFrom.StackFacing
  616.     DragCards.Move cx%, cy%
  617.     DragCards.Visible = True
  618.     c% = cFrom.RemoveCard(idx%)
  619.     For i% = 0 To steps%
  620.         dx% = (tx% - cx%) \ (steps% - i% + 1)
  621.         dy% = (ty% - cy%) \ (steps% - i% + 1)
  622.                 
  623.         cx% = cx% + dx%
  624.         cy% = cy% + dy%
  625.         
  626.         DragCards.Move cx%, cy%
  627.     Next
  628.     DragCards.StackFacing = cTo.StackFacing
  629.     cTo.TopCard = DragCards.Card(0)
  630.     DragCards.Visible = False
  631.     DoEvents
  632.     Sleep 0.1
  633. End Sub
  634. Private Sub Briscola_Change()
  635.     ' record suit for faster access, remembers it
  636.     ' even when the briscola has been picked up.
  637.     If Briscola.NumCards > 0 Then
  638.         Game_BriscolaSuit = Briscola.Suit(0)
  639.     End If
  640. End Sub
  641. ' trace what is happening on the table in terms of
  642. ' game logic, for debugging purposes.
  643. Private Sub OnTable_Trace(order%)
  644.     Dim pl%, p$, s$
  645.     If Not App_Debug Then Exit Sub
  646.     Trace "OnTable_Change " & order% & " cards, was " & OnTable.Tag
  647.     pl% = Hand_PlayerTurn
  648.     If pl% = 0 Then pl% = 2
  649.     p$ = Game_PlayerName(Hand_PlayerTurn)
  650.     Select Case order%
  651.         Case 0
  652.             ' not interesting
  653.         
  654.         Case 1
  655.             ' just removing cards, still not interesting
  656.             If Val(OnTable.Tag) = 2 Then Exit Sub
  657.         
  658.             ' a card was added, this is interesting
  659.             s$ = "--> Hand " & Hand_Number & "  - Player " & pl% & " (" & p$ & ")"
  660.             s$ = s$ & "  - Briscola: " & CardName$(Briscola.Card(0))
  661.             Trace s$
  662.                 
  663.         Case 2
  664.             ' both cards player, this is the outcome of hand
  665.             s$ = "--> Hand " & Hand_Number & "  - Player " & pl% & " (" & p$ & ")"
  666.             s$ = s$ & "  - Briscola: " & CardName$(Briscola.Card(0))
  667.             Trace s$
  668.             
  669.             s$ = "--> C1=" & CardName$(Hand_CardPlayer1) & ",  C2=" & CardName$(Hand_CardPlayer2)
  670.             s = s$ & "  - Winner is " & Hand_Winner
  671.             Trace s$
  672.     End Select
  673. End Sub
  674. Private Sub FileExit_Click()
  675.     If Game_AllowAbort() Then
  676.         Unload Me
  677.     End If
  678. End Sub
  679. Private Sub FileHint_Click()
  680.     Game_GiveHint
  681. End Sub
  682. Private Sub FileNew_Click()
  683.     Game_New
  684. End Sub
  685. Private Sub FileOpen_Click()
  686.     Dim fn$
  687.     On Error GoTo cancel_load
  688.     If Game_AllowAbort() Then
  689.         DialogObj.DialogTitle = "Open " & App_FileType$
  690.         DialogObj.DefaultExt = App_FileExt$
  691.         DialogObj.Flags = (OFN_HIDEREADONLY Or OFN_SHOWHELP)
  692.         If Game_FileName$ <> Game_NoFileName$ Then
  693.             DialogObj.FileName = Game_FileName$
  694.         Else
  695.             DialogObj.FileName = ""
  696.         End If
  697.         DialogObj.Filter = App_FileType$ & "|*." & App_FileExt$ & "|All Files|*.*"
  698.         DialogObj.CancelError = True
  699.         DialogObj.Action = CD_OPENFILE
  700.         fn$ = DialogObj.FileName
  701.         If fn$ <> "" Then
  702.             
  703.             Table_Disable "Opening '" & FilePart$(fn$) & "'..."
  704.             Game_Open fn$
  705.             RecentFile_AddItem Game, Game_FileName$
  706.             Table_Enable
  707.         End If
  708.     End If
  709. cancel_load:
  710.     Exit Sub
  711. End Sub
  712. Private Sub FilePause_Click()
  713.     FilePause.Checked = Not FilePause.Checked
  714.     Game_Pause FilePause.Checked
  715.     If FilePause.Checked Then
  716.         ToolButton(BTN_PAUSE).Caption = "Resume"
  717.     Else
  718.         ToolButton(BTN_PAUSE).Caption = "Pause"
  719.     End If
  720. End Sub
  721. Private Sub FileRecent_Click(Index As Integer)
  722.     Dim fn$
  723.     fn$ = RecentFile_Item$(Game, Index)
  724.     If Game_AllowAbort() Then
  725.         Table_Disable "Opening '" & FilePart$(fn$) & "'..."
  726.         Game_Open fn$
  727.         Table_Enable
  728.     End If
  729. End Sub
  730. Private Sub FileSave_Click()
  731.     If Game_FileName$ = "Unnamed" Then
  732.         FileSaveAs_Click
  733.     Else
  734.         Table_Disable "Saving '" & FilePart$(Game_FileName$) & "'..."
  735.         Game_Save Game_FileName$
  736.         Table_Enable
  737.     End If
  738. End Sub
  739. Private Sub FileSaveAs_Click()
  740.     Dim fn$
  741.     On Error GoTo cancel_save
  742.     DialogObj.DialogTitle = "Open " & App_FileType$
  743.     DialogObj.DefaultExt = App_FileExt$
  744.     DialogObj.FileName = Game_FileName$
  745.     DialogObj.Filter = App_FileType$ & "|*." & App_FileExt$ & "|All Files|*.*"
  746.     DialogObj.CancelError = True
  747.     DialogObj.Flags = (OFN_HIDEREADONLY Or OFN_SHOWHELP)
  748. retry:
  749.     DialogObj.Action = CD_SAVEFILE
  750.     fn$ = DialogObj.FileName
  751.     If fn$ <> "" Then
  752.         
  753.         DoSave = True
  754.         If FileExists(fn$) = True Then
  755.             Select Case AskOverWrite(fn$)
  756.             Case IDNO
  757.                 GoTo retry
  758.             Case IDCANCEL
  759.                 DoSave = False
  760.             End Select
  761.         End If
  762.         If DoSave = True Then
  763.             Table_Disable "Saving as '" & FilePart$(fn$) & "'..."
  764.             Game_Save fn$
  765.             RecentFile_AddItem Game, Game_FileName$
  766.             Table_Enable
  767.         End If
  768.     End If
  769. cancel_save:
  770.     Exit Sub
  771. End Sub
  772. Private Sub FileStop_Click()
  773.     Game_Finish True
  774. End Sub
  775. Private Sub Form_KeyPress(KeyAscii As Integer)
  776.     ' ESC can be used to quit a Demo
  777.     If KeyAscii = 27 Then
  778.         If Game_Mode = MODE_DEMO Then
  779.             Game_ModeNormal
  780.         End If
  781.     End If
  782. End Sub
  783. Private Sub Layout()
  784.     Dim h As Long, bdr_h As Integer, bdr_w As Integer
  785.     Static laying_out As Integer
  786.     ' avoid recursion
  787.     If laying_out = True Then Exit Sub
  788.     laying_out = True  ' avoid recursion
  789.     h = 0
  790.     bdr_h = Game.Height - Game.ScaleHeight    ' border sizes
  791.     bdr_w = Game.Width - Game.ScaleWidth      ' border sizes
  792.     If ToolBar.Visible Then
  793.         h = h + ToolBar.Height
  794.     End If
  795.         
  796.     Table.Top = h
  797.     h = h + Table.Height
  798.     If StatusLine.Visible Then
  799.         h = h + StatusLine.Height
  800.     End If
  801.     ' can resize only if not minimized or maximized
  802.     If Me.WindowState = 0 Then Game.Height = h + bdr_h
  803.     Table.Width = Game.ScaleWidth
  804.     laying_out = False
  805. End Sub
  806. Private Sub Form_LinkClose()
  807.     MsgBox Game.Player2Name & " disconnected"
  808.     Game_Disconnect
  809.     Game_ModeNormal
  810. End Sub
  811. Private Sub Form_LinkError(LinkErr As Integer)
  812.     MsgBox Game.Player2Name & " disconnected"
  813.     Game_Disconnect
  814.     Game_ModeNormal
  815. End Sub
  816. ' Invoked by partner with:
  817. ' CmdStr = RemoteHost + "," + RemotePlayerName
  818. Private Sub Form_LinkExecute(CmdStr As String, Cancel As Integer)
  819.     Dim s$, r%, Cmd$
  820.     If App_Debug Then Trace "LinkExecute " & CmdStr
  821.     Cmd$ = Left$(CmdStr, 1)
  822.     Select Case Cmd$
  823.         Case "C"    ' connect
  824.             Game_Accept Mid$(CmdStr, 1), Cancel
  825.         Case "R"    ' restart
  826.             Game_Start
  827.         Case Else
  828.             MsgBox "Invalid Network Command"
  829.     End Select
  830. End Sub
  831. Private Sub Form_Load()
  832.     Layout
  833.     Table_Clear
  834.     Form_SetTitle Me
  835.     Form_Center Me
  836.     Game_SetDefaults
  837.     Game_Listen
  838. End Sub
  839. Private Sub Form_Resize()
  840.     Layout
  841. End Sub
  842. Private Sub Form_Unload(Cancel As Integer)
  843.     App_Close Game
  844.     End
  845. End Sub
  846. Private Sub GameTimer_Timer()
  847.     ' prevent recursion in case someone yields
  848.     GameTimer.Enabled = False
  849.     If App_Debug Then Trace "Game_Timer"
  850.     ' Still need to connect back over network?
  851.     If Game_Mode = MODE_NETWORK And Player1.LinkMode = 0 Then
  852.         Game_ConnectBack
  853.         Exit Sub
  854.     End If
  855.     ' Normal Play. Don't play if minimized
  856.     If Game_InProgress And Not WindowStatus = 1 Then
  857.         
  858.         ' players finished a hand
  859.         If Game.OnTable.NumCards = 2 Then
  860.             Hand_Next
  861.         ' check if we have to play some side
  862.         Else
  863.             Game_AutoPlay
  864.         End If
  865.         
  866.     End If
  867.     ' reschedule ourselves
  868.     GameTimer.Enabled = True
  869. End Sub
  870. Private Sub HelpAbout_Click()
  871.     AboutForm.Show
  872. End Sub
  873. Private Sub HelpContents_Click()
  874.     Help_Conts
  875. End Sub
  876. Private Sub HelpUsingHelp_Click()
  877.     Help_UsingHelp
  878. End Sub
  879. Private Sub OptAnimate_Click()
  880.     OptAnimate.Checked = Not OptAnimate.Checked
  881. End Sub
  882. Private Sub mGameOptions_Click()
  883.     Game_Options
  884. End Sub
  885. ' Note Well:
  886. ' The game may be linked over DDE to another one
  887. ' For this reason, game state transition must be
  888. ' triggered by changed in this control, NOT by
  889. ' explicit calls when dealing or playing cards!
  890. Private Sub OnTable_Change()
  891.     If Not Game_InProgress Then Exit Sub
  892.     If App_Debug Then Trace "OnTable_Change"
  893.     Select Case OnTable.NumCards
  894.         
  895.         Case 0
  896.             ' deck was cleared, allow players to play
  897.             Hand_Clear
  898.             
  899.         Case 1
  900.             ' Check that we are ADDING cards, not removing
  901.             ' if so, previous # of card was 0. Switch sides
  902.             If Val(OnTable.Tag) = 0 Then
  903.                 Hand_SwitchPlayer
  904.             End If
  905.         Case 2
  906.             Hand_CheckWinner
  907.     End Select
  908.     If App_Debug Then OnTable_Trace OnTable.NumCards
  909.     ' stash current # of cards, so next time we know what happened
  910.     OnTable.Tag = OnTable.NumCards
  911. End Sub
  912. Private Sub OptPeek_Click()
  913.     OptPeek.Checked = Not OptPeek.Checked
  914.     If OptPeek.Checked Then
  915.         Player2.StackFacing = CARDS_FACING_UP
  916.     Else
  917.         Player2.StackFacing = CARDS_FACING_DOWN
  918.     End If
  919. End Sub
  920. Private Sub OptSound_Click()
  921.     OptSound.Checked = Not OptSound.Checked
  922. End Sub
  923. Private Sub OptStatusBar_Click()
  924.     OptStatusBar.Checked = Not OptStatusBar.Checked
  925.     StatusLine.Visible = OptStatusBar.Checked
  926.     Layout
  927. End Sub
  928. Private Sub OptToolBar_Click()
  929.     OptToolBar.Checked = Not OptToolBar.Checked
  930.     ToolBar.Visible = OptToolBar.Checked
  931.     Layout
  932. End Sub
  933. Private Sub OptTrace_Click()
  934.     OptTrace.Checked = Not OptTrace.Checked
  935.     TraceMode (OptTrace.Checked)
  936. End Sub
  937. Private Sub Player1_Change()
  938.     If App_Debug Then Trace "Player1_Change: " & Player1.Count(0) & " cards"
  939. End Sub
  940. Private Sub Player1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  941.     If Player1_AutoPlay Then Exit Sub
  942.     If Player1.Current <> CARD_NONE Then Player1.Selected(Player1.Current) = True
  943. End Sub
  944. Private Sub Player1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  945.     If Player1_AutoPlay Then Exit Sub
  946.     If Player1.Current <> CARD_NONE Then Player1.Selected(Player1.Current) = False
  947.     If Hand_CanPlay(1) And Player1.Current <> CARD_NONE Then
  948.         Hand_PlayCard Player1, Player1.Current
  949.     End If
  950. End Sub
  951. Private Sub Player2_Change()
  952.     If App_Debug Then Trace "Player 2 Changed: " & Player2.Count(0)
  953. End Sub
  954. Private Sub Player2_Click()
  955.     If Not Game_InProgress Then Exit Sub
  956.     If Not OptPeek.Checked Then
  957.         Game.MessageView = Game_PlayerName(1) & NOT_YOUR_CARDS
  958.     End If
  959. End Sub
  960. Private Sub Stack1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  961.     If OptPeek.Checked Then
  962.         Stack1.SpreadStyle = CARDS_SPREAD_TIGHT
  963.         Stack1.SpreadDir = CARDS_SPREAD_RIGHT
  964.         Stack1.Action = CARDS_ACTION_TURN_UP
  965.     End If
  966. End Sub
  967. Private Sub Stack1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  968.     Stack1.SpreadStyle = CARDS_SPREAD_SLANTED
  969.     Stack1.SpreadDir = CARDS_SPREAD_UP_RIGHT
  970.     Stack1.Action = CARDS_ACTION_TURN_DOWN
  971. End Sub
  972. Private Sub Stack2_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  973.     If OptPeek.Checked Then
  974.         Stack2.SpreadStyle = CARDS_SPREAD_TIGHT
  975.         Stack2.SpreadDir = CARDS_SPREAD_RIGHT
  976.         Stack2.Action = CARDS_ACTION_TURN_UP
  977.     End If
  978. End Sub
  979. Private Sub Stack2_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  980.     Stack2.SpreadStyle = CARDS_SPREAD_SLANTED
  981.     Stack2.SpreadDir = CARDS_SPREAD_UP_RIGHT
  982.     Stack2.Action = CARDS_ACTION_TURN_DOWN
  983. End Sub
  984. Private Sub ToolButton_MouseDown(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
  985.     ' Display help message associated with this button
  986.     Game_Msg (ToolButton(Index).Tag)
  987. End Sub
  988. Private Sub ToolButton_MouseUp(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
  989.     ' Clear the help message
  990.     Game_Msg ""
  991.     ' Do not trigger command if mouse is release outside button
  992.     If x < 0 Or y < 0 Or x > ToolButton(Index).Width Or y > ToolButton(Index).Height Then Exit Sub
  993.     Select Case Index
  994.         Case BTN_START
  995.             FileNew_Click
  996.         
  997.         Case BTN_PAUSE
  998.             FilePause_Click
  999.             
  1000.         Case BTN_STOP
  1001.             FileStop_Click
  1002.         
  1003.         Case BTN_FILEOPEN
  1004.             FileOpen_Click
  1005.         
  1006.         Case BTN_FILESAVE
  1007.             FileSave_Click
  1008.         
  1009.         Case BTN_HINT
  1010.             Game_GiveHint
  1011.         
  1012.     End Select
  1013. End Sub
  1014.